package com.xinqi.common.openfeign;

import com.xinqi.common.base.utils.json.JSON;
import com.xinqi.common.openfeign.ext.JacksonDecoder;
import com.xinqi.common.openfeign.interceptor.FeignRequestInterceptor;
import feign.RequestInterceptor;
import feign.codec.Decoder;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author linkai
 * @date 2023/3/10
 */
@Configuration(proxyBeanMethods = false)
@AutoConfigureBefore(FeignAutoConfiguration.class)
public class OpenFeignConfig {
    @Bean
    public Decoder feignDecoder() {
        return new JacksonDecoder(JSON.mapper());
    }

    @Bean
    public RequestInterceptor requestInterceptor() {
        return new FeignRequestInterceptor();
    }
}
